package com.example.dryyzx.dao;

import com.example.dryyzx.entity.Order;
import org.apache.ibatis.jdbc.SQL;

public class OrderSqlProvider {
    public String insertSelective(Order record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("`order`");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getCustomerId() != null) {
            sql.VALUES("customer_id", "#{customerId,jdbcType=INTEGER}");
        }
        
        if (record.getFoodId() != null) {
            sql.VALUES("food_id", "#{foodId,jdbcType=INTEGER}");
        }
        
        if (record.getEnable() != null) {
            sql.VALUES("enable", "#{enable,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Order record) {
        SQL sql = new SQL();
        sql.UPDATE("`order`");
        
        if (record.getCustomerId() != null) {
            sql.SET("customer_id = #{customerId,jdbcType=INTEGER}");
        }
        
        if (record.getFoodId() != null) {
            sql.SET("food_id = #{foodId,jdbcType=INTEGER}");
        }
        
        if (record.getEnable() != null) {
            sql.SET("enable = #{enable,jdbcType=BIT}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}